<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
name = name;
<input type="text" name="name">
<input type="text" name="name">
<input type="text" name="name">
<input type="text" name="name">
<input type="text" name="name">
<p>
id=myid
<input type="text" name="age" id="myid">
<input type="text" name="age" id="myid">
<input type="text" name="age" id="myid">
<p>
textarea
<textarea></textarea>
<textarea></textarea>
<textarea></textarea>
<p>

<p name="txt">안녕</p>
<div name="txt">Hello</div>
<p name="txt">홍길동</p>

<input type="button" onclick="findByName()" value="findByName">
<input type="button" onclick="findById()" value="findById">
<input type="button" onclick="findByTagName()" value="findByTagName">
<input type="button" onclick="findByName2()" value="findByName2">


<script type="text/javascript">
function findByName2() {
	var tags = document.getElementsByName("txt");
	for(var i=0; i<tags.length; i++)	{
		tags[i].style.color="pink";
		tags
		[i].style.fontWeight="bold";
	}
}

function findByTagName() {
	//문서 내의 textarea 객체들을 배열(NodeList)로 리턴
	var tags = document.getElementsByTagName("textarea");
	for(var i=0; i<tags.length; i++) {
		tags[i].rows= 5;
		tags[i].cols=30;
		tags[i].value="이것은 TA 입니다";
	}
}


function findById() {
	var tag = document.getElementById("myid");//DOM 객체 리턴.id="myid"
	tag.value="내나이는 30살 입니다.";
	tag.size=40;
}


function findByName() {
	var tags = document.getElementsByName("name");// Node List(배열)// name="name"
	for(var i=0; i<tags.length; i++) {
	tags[i].value = "안녕하세요";	
	}
}
</script>

</body>
</html>